<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <title>常用文档</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
</head>
<style>
    .content {
        padding: 8px 8px 0 8px;
    }
    .fixed-table_body tr td {
        border-right: none;
        font-size: 12px;
        text-align: center;
        height: 24px;
        max-height: 24px;
        overflow: hidden;
    }

    .fixed-table_header tr th {
        border-right: none;
        background: yellow;
        font-weight: normal;
        font-size: 12px;
        text-align: center;
    }

    .fixed-table_body tr:nth-of-type(odd) {
        background: #F9F9F9;
    }
</style>
<body>
<section class="content"  id="app" v-cloak>
    <div id="dev" style="height: 25px; margin-bottom: 10px;">
        <div class="pull-left" style="width: 120px;">
            <select id="selectCompany" style="    width: 100%;height: 25px;font-size: 12px;line-height: 25px;padding-top: 0px;padding-bottom: 0px;padding-left: 6px;" v-model="selectCom"  >
                <option value="">请选择公司</option>
                <option v-for="item in companyList" v-bind:value="item.id">{{item.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="width: 120px;margin-left: 10px;">
            <select id="selectRole"  v-model="selectDep" style="    width: 100%;height: 25px;font-size: 12px;line-height: 25px;padding-top: 0px;padding-bottom: 0px;padding-left: 6px;"  >
                <option value="">请选择部门</option>
                <option value="销售部">销售部</option>
                <option value="服务部">服务部</option>
                <option value="其他">其他</option>
            </select>
        </div>
        <input type="text"  v-model="key" placeholder="关键字" class="form-control pull-left input-sm" style="width: 120px; margin-left: 10px;" >
        <!--根据条件查询-->
        <input type="button" value="查询" class="btn oaBtn btn-sm pull-left"  @click="sel()" style="margin-left: 10px;">
        <input type="button" value="新建" class="btn oaBtn btn-sm pull-right"  @click="add()">
    </div>
    <div class="box-body no-padding iframeH3" style="overflow: auto;" id="scrollDiv" >
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                        <tr>
                            <th style="width:60px;" class="tableTitle">序号</th>
                            <th class="tableTitle">文档名称</th>
                            <th style="width:100px;" class="tableTitle">公司</th>
                            <th style="width:80px;" class="tableTitle">部门</th>
                            <th style="width:80px;" class="tableTitle">文档类型</th>
                            <th style="width:60px;" class="tableTitle">创建人</th>
                            <th style="width:120px;" class="tableTitle">操作</th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table_body-wraper iframeFileListFixed">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;">
                    <tbody>
                    <tr v-for="(item,i) in list">
                        <td style="width:60px;">{{i+1}}</td>
                        <td style="text-align:left;">
                            {{item.docName}}
                        </td>
                        <td style="width:100px;">
                            {{item.companyName}}
                        </td>
                        <td style="width:80px;">
                            {{item.departName}}
                        </td>
                        <td style="width:80px;">
                            {{item.typeName}}
                        </td>
                        <td style="width:60px;">
                            {{item.userName}}
                        </td>
                        <td style="width:120px;">
                            <span v-if="item.typeName!='calculator'"><a @click="gotoDetail(item.id,item.typeName)" style="cursor: pointer">修改</a></span>
                            <span><a @click="lookDetail(item.id,item.typeName,item)" style="cursor: pointer">查看</a></span>
                            <span ><a @click="deleteFile(item.id)" style="cursor: pointer">删除</a></span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!--<table class="table table-hover text-center" >-->
            <!--<thead><tr>-->
                <!--<th style="width:60px;" class="tableTitle">序号</th>-->
                <!--<th class="tableTitle">文档名称</th>-->
                <!--<th style="width:100px;" class="tableTitle">公司</th>-->
                <!--<th style="width:80px;" class="tableTitle">部门</th>-->
                <!--<th style="width:80px;" class="tableTitle">文档类型</th>-->
                <!--<th style="width:60px;" class="tableTitle">创建人</th>-->
                <!--<th style="width:120px;" class="tableTitle">操作</th>-->
            <!--</tr>-->
            <!--</thead>-->
            <!--<tbody>-->
            <!--<tr v-for="(item,i) in list">-->
                <!--<td>{{i+1}}</td>-->
                <!--<td style="text-align:left;">-->
                    <!--{{item.docName}}-->
                <!--</td>-->
                <!--<td>-->
                    <!--{{item.companyName}}-->
                <!--</td>-->
                <!--<td>-->
                    <!--{{item.departName}}-->
                <!--</td>-->
                <!--<td>-->
                    <!--{{item.typeName}}-->
                <!--</td>-->
                <!--<td>-->
                    <!--{{item.userName}}-->
                <!--</td>-->
                <!--<td>-->
                    <!--<span v-if="item.typeName!='calculator'"><a @click="gotoDetail(item.id,item.typeName)" style="cursor: pointer">修改</a></span>-->
                    <!--<span><a @click="lookDetail(item.id,item.typeName,item)" style="cursor: pointer">查看</a></span>-->
                    <!--<span ><a @click="deleteFile(item.id)" style="cursor: pointer">删除</a></span>-->
                <!--</td>-->
            <!--</tr>-->
            <!--</tbody></table>-->

    </div>
    <div class="oa-pager text-center" style="margin-top: 5px;">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script type="text/javascript">
    console.log(urlConfig);
    var app = new Vue({
        el:'#app',
        data:{
            currentUser:getCurrentUser(),
            selectCom: "",
            selectDep:"",
            key:"",
            list: [],
            companyList:[]
        },
        methods:{
            /*根据选中条件查询设备信息(无法获取传回来的records)*/
            sel: function(){
                var that = this;
                var data = {
                    'companyId': that.selectCom,
                    'departName': that.selectDep,
                    'key': that.key
                };
                $.wyui.page.queryParams.requestPage = 1;
                $.extend($.wyui.page.queryParams,data);
                $.wyui.page.getByPage();

            },
            add: function(){
                $.dialog({
                    content: 'url:addType.html',
                    title: '创建文档',
                    width: 600,
                    height: 300,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            gotoDetail:function (id,type) {
                if(type=='word'){
                    top.closeTabByPageId("updateDetail");
                    url = "/commonFiles/wordDetail.html?fileId="+id
                    top.addTabs({id: "updateDetail", title: "修改文档", close: true, url: url});
                }else if(type=='excel'){
                    url = "/commonFiles/excelDetail.html?fileId="+id
                    top.addTabs({id: "updateDetail", title: "修改文档", close: true, url: url});
                }
            },
            lookDetail:function (id,type,item) {
                top.closeTabByPageId("openDetail");
                url = "/commonFiles/lookFile.html?fileId="+id;
                top.addTabs({id: "openDetail", title: "查看文档", close: true, url: url});
            },
            deleteFile:function (id) {
                var that=this;
                if(confirm("确定要删除该文档吗？")){
                    $.wyui.postMethod(urlConfig.main.delById, {id:id}, function (r) {
                        that.sel();
                    });
                }
            }

        },
        mounted:function () {
            var that = this;
            var H = $(window).height();
            $(".iframeFileListFixed").height(H - 107);
            $.wyui.postMethod(urlConfig.system.company.getCompanyList, {}, function (r) {
                console.log(r);
                that.companyList=r;
            });
        }
    });
    $(window).resize(function () {
        var H = $(window).height();
        $(".iframeFileListFixed").height(H - 107);
    })
    $.wyui.page.dataUrl = server.ip + urlConfig.main.getMainByPage;
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams);
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        }
    };
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);
            }
            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
</script>
</body>
</html>